package com.cci.kangdao.dao;


import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

//同步确认维修信息到crm异常重传处理表
public interface ExceptionDataSyncCrmTDao {


    int insert(Map<String, Object> map);

    @Select("select * from ExceptionDataSyncCrm_T where Flag = 0 and IsSyncSuccess = 0")
    List<Map<String, Object>> getExceptionDataSyncCrmTSyncFailureList();


    @Select(" <script> select * from ExceptionDataSyncCrm_T where Flag = 0 and IsSyncSuccess = 0 and ID in  <foreach collection='ids' item='item' open='(' separator=',' close=')'>#{item} </foreach> </script>")
    List<Map<String, Object>> getExceptionDataSyncCrmTSyncFailureListByIds(@Param("ids") List<String> ids);

    @Update({"<script>",
            "update ExceptionDataSyncCrm_T",
            "<set>",
            "<if test='IsSyncSuccess != null and IsSyncSuccess != -1'>",
            "IsSyncSuccess = #{IsSyncSuccess} ,",
            "</if>",
            "<if test='FailReason != null and FailReason !=\"\" '>",
            "FailReason = #{FailReason} ,",
            "</if>",
            "SyncNum = SyncNum+1,Updator = #{Updator},UpdateTime = #{UpdateTime}",
            "</set>",
            "where ID = #{ID}",
            "</script>"})
    int update(Map<String,Object> map);

}